﻿/// <reference path="jquery-1.7-vsdoc.js" />
/// <reference path="MyLibrary.js" />




(function(window){
    function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
} 
  



})(window)











if (window.attachEvent) {
    window.attachEvent("onload", windowsReady);
}
else {
    window.addEventListener("onload", windowsReady);
}

function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function stateChanged(event) {
    if (event.target.readyState == 4) {
        var objectData = JSON.parse(event.target.responseText).d;
        var object = JSON.parse(objectData)
        var responseHeaders = event.target.getAllResponseHeaders();
        var arrayHeaders = responseHeaders.split(/\n/);
        var objectHeaders = changeArrayToObject(arrayHeaders, ":");
        document.getElementById("result").setAttribute("value", object.william);
    }
}


function windowsReady(event) {
    var get = document.getElementById("get");
    var text = document.getElementById("result");
    get.attachEvent("onclick", function () {
        var xmlHttp = GetXmlHttpObject();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("Post", "Json.aspx/GetJsonWithParams", true);
        xmlHttp.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
        xmlHttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        var object = new Object();
        object.key = "william";
        object.value = 12;
        var jsonStr = JSON.stringify(object);
        xmlHttp.send(jsonStr);
    });

    //    var object = new Object();
    //    object.name = "william";
    //    object.age = 12;
    //    var jsonStr = JSON.stringify(object);
    //    var object = JSON.parse(jsonStr);
    //    alert(object.name);
    //alert(navigator.userAgent);
    //alert(get.getAttribute("value"));

        var object1 = new Object();
        object1.name = "william";
        object1.age = 12;
        var object2 = new Object();
        object2.name = "wang";
        object2.score = 24;
        var object3 = { name: "王吉彬", sum: "100" };
        var objectMerge = mergeObject(object1, object2, object3);
        Convert.strToInt("erwr");
        
}




var ev = $.Event("click", "");
ev.

//$(document).ready(function () {
//    var test = "Hello";
//    alert(test);
//});



